<template>
    <nav class="navbar navbar-expand-lg bg-body-tertiary">
        <div class="container-fluid container">
            <a class="navbar-brand" href="#">小吃摊车</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarSupportedContent">
                <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                    <li class="nav-item">
                    <router-link class="nav-link active" aria-current="page" :to="{ name: 'home' }">首页</router-link>
                    </li>
                    <li class="nav-item">
                    <router-link class="nav-link" :to="{ name: 'burglaryproofdoor' }" v-if="!$store.state.user.is_superuser">防盗门专览</router-link>
                    </li>
                    <li class="nav-item">
                    <router-link class="nav-link" :to="{ name: 'homerollerdoor' }" v-if="!$store.state.user.is_superuser">卷帘门专览</router-link>
                    </li>
                    <li class="nav-item">
                    <router-link class="nav-link" :to="{ name: 'foodcart' }" v-if="!$store.state.user.is_superuser">小吃车专览</router-link>
                    </li>
                    <li class="nav-item">
                    <router-link class="nav-link" :to="{ name: 'myshelves' }" v-if="!$store.state.user.is_superuser">我的货架</router-link>
                    </li>
                    <li class="nav-item">
                    <router-link class="nav-link" :to="{ name: 'contact', params: {userid: 7} }" v-if="!$store.state.user.is_superuser">联系我们</router-link>
                    </li>
                    <li class="nav-item">
                    <router-link class="nav-link" :to="{ name: 'login' }" v-if="!$store.state.user.is_login">登录</router-link>
                    </li>
                    <li class="nav-item">
                    <router-link class="nav-link" :to="{ name: 'register' }" v-if="!$store.state.user.is_login">注册</router-link>
                    </li>
                    <li class="nav-item">
                    <router-link class="nav-link" :to="{ name: 'warehouse' }" v-if="$store.state.user.is_superuser">仓储管理</router-link>
                    </li>
                    <li class="nav-item">
                    <router-link class="nav-link" :to="{ name: 'recentnews' }" v-if="$store.state.user.is_superuser">最近消息</router-link>
                    </li>
                    <li class="nav-item">
                    <a class="nav-link" v-if="$store.state.user.is_login" style="cursor: pointer;" @click="logout">退出</a>
                    </li>
                    <li class="nav-item">
                    <a class="nav-link" v-if="$store.state.user.is_login" style="cursor: pointer; font-weight: bolder;">{{ $store.state.user.username }}</a>
                    </li>
                    <!-- <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                        Dropdown
                    </a>
                    <ul class="dropdown-menu">
                        <li><a class="dropdown-item" href="#">Action</a></li>
                        <li><a class="dropdown-item" href="#">Another action</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="#">Something else here</a></li>
                    </ul>
                    </li> -->
                    <!-- <li class="nav-item">
                    <a class="nav-link disabled">Disabled</a>
                    </li> -->
                </ul>
                <form class="d-flex" role="search">
                    <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
                    <button class="btn btn-outline-success" type="submit">Search</button>
                </form>
            </div>
        </div>
    </nav>
</template>

<script>
import { useStore } from 'vuex';
export default {
    name: "NavBar",
    setup() {
        const store = useStore();
        const logout = () => {
            store.commit('logout');
        }
        return {
            logout,
        }
    }
}
</script>

<style>
</style>